package com.qidian.mes.qc.service.impl;/**
 * ClassName:MaterialProductServiceiMPL
 * Package:com.qidian.mes.qc.service.impl
 **/

import com.qidian.mes.pojo.Material;
import com.qidian.mes.pojo.MaterialProduct;
import com.qidian.mes.qc.mapper.MaterialProductMapper;
import com.qidian.mes.qc.service.MaterialProductService;
import com.qidian.mes.util.dot.PagerDTO;
import com.qidian.mes.util.pojo.QdResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @Author ppc
 * @Conpany study
 * @Description:
 * @Time 2024/4/13 9:56
 *
 **/
@Service
public class MaterialProductServiceImpl implements MaterialProductService {

    @Autowired
    private MaterialProductMapper materialProductMapper;

    @Override
    public QdResult<PagerDTO<MaterialProduct>> queryAllByPage(String templateId, Integer page, Integer limit) {
        PagerDTO pagerDTO = new PagerDTO();
        pagerDTO.setLimit(limit);
        pagerDTO.setPage(page);
        pagerDTO.setTotal(materialProductMapper.selectCount(templateId));
        pagerDTO.setData(materialProductMapper.selectAllByPage(templateId,limit*(page-1),limit));
        return QdResult.success(pagerDTO);
    }

    @Override
    public QdResult queryAll() {
        return QdResult.success(materialProductMapper.selectAll());
    }


    @Override
    public QdResult insert(MaterialProduct materialProduct) {
        materialProductMapper.insert(materialProduct);
        return QdResult.success();
    }

    @Override
    public QdResult update(MaterialProduct materialProduct) {
        materialProductMapper.update(materialProduct);
        return QdResult.success();
    }

    @Override
    public QdResult delete(String materialProductId) {
        materialProductMapper.delete(materialProductId);
        return QdResult.success();
    }

    @Override
    public QdResult deletes(String[] materialProductIds) {
        materialProductMapper.deletes(materialProductIds);
        return QdResult.success();
    }

    @Override
    public QdResult<MaterialProduct> queryById(String materialProductId) {
        return QdResult.success(materialProductMapper.selectById(materialProductId));
    }
}
